﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Xyz.Web.Reservation.Models.TripListModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Choose
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Choose Flight</h2>
        <br />
    <% using (Html.BeginForm())
       { %>
    <%= Html.ValidationSummary(true)%>
    <br />
        <% if(Model != null) {
            foreach (Xyz.Web.Reservation.Models.TripModel trip in ViewData.Model.Trips) { %>
            <fieldset>
            <table cellspacing="0" cellpadding="2">
                <tr>
                    <td style="width: 166px;">
                        <h4><%: Html.DisplayTextFor(t => trip.TripType) %></h4>
                    </td>
                    <td>
                        <h4><%= Html.Label(string.Format("{0:dd-MMM-yyyy}", trip.TripDate))%></h4>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <% foreach (Xyz.Web.Reservation.Models.ChooseFlightModel chooseFlight in trip.ChooseFlights) { %>
                            <table style="border-top: 1px dotted #DDDDDD;" cellspacing="0" cellpadding="5px">
                                <tr style='background-color: <% = (chooseFlight.FlightId == trip.FlightId) ? "#EEEEEE" : "#FFFFFF" %>'>
                                    <td style="width:65px;">
                                        <% if (chooseFlight.FlightId == trip.FlightId)
                                           { %>
                                                Selected
                                           <% } 
                                           else if (!chooseFlight.Available)
                                           { %>
                                                &nbsp;
                                        <% }
                                           else
                                           { %>
                                                <%: Html.ActionLink("Select", "Choose", new { FlightId = chooseFlight.FlightId, TripType = trip.TripType })%>
                                        <% } %>
                                    </td>
                                    <td style="width:80px;">
                                        <% if (chooseFlight.FlightId == trip.FlightId)
                                           { %>
                                        <span style="font-size:large;"><%= chooseFlight.FlightCode %></span>
                                        <% } else { %>
                                                 <%: Html.DisplayTextFor(f => chooseFlight.FlightCode) %>
                                        <% }  %>
                                    </td>
                                    <td style="width:210px;">
                                        <b>Departing</b>
                                        <br />
                                        <%: Html.DisplayTextFor(f => chooseFlight.DepartureAirport) %>
                                        <br />
                                         <span><%= string.Format("{0:dd-MMM-yyyy(ddd)  HH:mm (hh:mm tt)}", chooseFlight.DepartureDateTime)%></span>
                                    </td>
                                    <td style="width:210px;">
                                        <b>Arriving</b>
                                        <br />
                                        <%: Html.DisplayTextFor(f => chooseFlight.ArrivalAirport) %>
                                        <br />
                                        <span><%= string.Format("{0:dd-MMM-yyyy (ddd)  HH:mm (hh:mm tt)}", chooseFlight.ArrivalDateTime)%></span>
                                    </td>
                                    <td style="width:130px; vertical-align: top;">
                                        <b>Total Travel Time</b>
                                        <br />
                                        <span><%= string.Format("{0:#0hrs}", chooseFlight.TravelTime.Hours)%> <%= string.Format("{0:#0mins}", chooseFlight.TravelTime.Minutes)%></span>
                                    </td>
                                    <td style="width:70px;">
                                        <span><%= (chooseFlight.Available ? "Available" : "Not Avaliable") %></span>
                                    </td>
                                    <td style="width:100px; text-align:right;">
                                        <% if (chooseFlight.FlightId == trip.FlightId)
                                           { %>
                                        <span style="font-size:large;"><%= string.Format("{0:$ #,##0.00}", chooseFlight.TotalFare)%></span>
                                        <% } else { %>
                                        <span><%= string.Format("{0:$ #,##0.00}", chooseFlight.TotalFare) %></span>
                                        <% }  %>
                                    </td>
                                </tr>
                            </table>
                            <% } %>
                    </td>
                </tr>
            </table>
            </fieldset>
            <% } %>
            <table cellspacing="0" cellpadding="2">
            <tr>
                <td style="width: 180px;">
                    Total No. of Passengers :
                </td>
                <td>
                    <span style="font-size:large;"><%= ViewData.Model.noOfPassenger %></span>
                </td>
            </tr>
            <tr>
                <td>
                    Total Ticket Fare : 
                </td>
                <td>
                    <span style="font-size:large; font-weight: bold; color: #000000;"><%= string.Format("{0:$ #,##0.00}", ViewData.Model.TotalTicketFare)%></span>
                </td>
            </tr>
        <% } %>
    </table>
    <br />
    <div>
        <input type="submit" value="    Next    " class="yellow_button" />
    </div>
    <br />
    <% } %>
</asp:Content>
